using HCI.Questionaire.Exceptions;

namespace HCI.Questionaire.Entities
{
    public class OneAnswerQuestion : Question
    {
        public override void ValidateAnswer()
        {
            int count = 0;
            this.AnswerCollection.ForEach(o => { if (o.IsAnswered) count++; });

            if (count > 1)
                throw new AnswerInvalidException("Answer cannot more than one.");

            if (count < 1)
                throw new RequiredAnswerException("Required at less on answer.");
        }
    }
}
